package middleware

import (
	"github.com/gin-gonic/gin"
	"github.com/rs/cors"
)

func Cors() gin.HandlerFunc {
	return func(c *gin.Context) {
		cors.New(cors.Options{
			AllowedOrigins: []string{"*"},
			AllowedMethods: []string{"*"},
			AllowedHeaders: []string{"origin"},
			ExposedHeaders: []string{"content-Length", "Authorization"},
			// AllowCredentials: true, // 是否发送cookie请求
			//MaxAge: int(12 * time.Hour),
		})
	}
}
